Fix overriding common_kwargs defaults in processor calls#41381
Merged
Conversation
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
zucchini-nlp
reviewed
Oct 7, 2025
Comment on lines
+1309
to
+1310
| common_kwargs = kwargs.get("common_kwargs", {}) | ||
| common_kwargs.update(ModelProcessorKwargs._defaults.get("common_kwargs", {})) |
Member
There was a problem hiding this comment.
in that case i think we want to change the order of these lines as well, instead of overriding user values by defaults
Contributor
Author
There was a problem hiding this comment.
Ah yes true, but should we even support that? It would be kind of weird for users to use a "common_kwargs" kwarg instead of just using return_tensors or other common_kwargs directly no?
Member
There was a problem hiding this comment.
yeah, i don't think anyone uses nested kwargs anyway. Just for correctness, if we support common kwargs, we should use whatever users can pass with priority imo
zucchini-nlp
approved these changes
Oct 7, 2025
This was referenced Oct 7, 2025
AhnJoonSung
pushed a commit
to AhnJoonSung/transformers
that referenced
this pull request
Oct 12, 2025
…#41381) * set common_kwargs defaults before updating with kwargs * change order to override defaults common_kwargs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
After #40931, the
common_kwargs(return_tensorsreally) defaults were set after updating them with call kwargs, which mean it's impossible to override the defaults.This fixes it by setting the common kwargs defaults before updating them with call kwargs, and fixes a test in
test_image_processing_owlv2.pythat was failing because of it (as Owlv2 sets return_tensors tonpby default for some reasons)Cc @zucchini-nlp to make sure I'm not missing anything!